package com.romotc.qqrobot.webqq.qqInterfaceCatching;

import java.io.IOException;
import java.util.Date;

import org.json.JSONException;
import org.json.JSONObject;

import com.romotc.scache.RequestSpy;
import com.romotc.scache.WebConnection;

/**
 * 检查请求的uin是否为负数，如果为负数则中断请求
 * @author Administrator
 *
 */
public class Get_qq_level2_Catching extends QQUrlCatchingInterface {

	public String modifyResponseBody(String origResPonseBody, RequestSpy rqSpy) {
		// TODO Auto-generated method stub
		return origResPonseBody;
	}

	@Override
	public boolean hackRequest(RequestSpy requestSpy) {
		// TODO Auto-generated method stub
		JSONObject jsonReqInfo = requestSpy.getReqInfoJson();
		int uin;
		try {
			uin = jsonReqInfo.getInt("tuin");
			if(uin < 0 ) {
				requestSpy.make_headers(500, null, null, null, 0, new Date()
				.getTime(), 0, null);
				requestSpy.send_headers();
				return false;
			}
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return true;
	}

	@Override
	public boolean modifyResponse(WebConnection wc, RequestSpy rqSpy)
			throws IOException {
		return false;
		
	}

}
